package com.ydl.learning.flink.demo

import org.apache.flink.streaming.api.functions.sink.PrintSinkFunction
import org.apache.flink.streaming.api.scala._

/**
 * 消费kafka demo
 *
 * @author ydl
 * @since 2020/6/30
 */
object KafkaDemo extends Utils {
  def main(args: Array[String]): Unit = {
    val dataStream: DataStream[(String, Int)] = streamEnv.addSource(consumer).setParallelism(2).flatMap(_.split("\\W")).map((_, 1))
    //dataStream.print()
    //和print()同样效果
    dataStream.addSink(new PrintSinkFunction[(String, Int)]())
    streamEnv.execute("Flink add kafka data source")

  }

}
